import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 考勤设置信息 */
export interface DeviceGateConfig {
  id: number // 编号
  scheduledEntryTime?: Dayjs // 规定入园时间
  scheduledExitTime?: Dayjs // 规定离园时间
  status?: number // 状态
}

// 考勤设置 API
export const DeviceGateConfigApi = {
  // 查询考勤设置分页
  getDeviceGateConfigPage: async (params: any) => {
    return await request.get({ url: `/school/device-gate-config/page`, params })
  },

  // 查询考勤设置详情
  getDeviceGateConfig: async () => {
    return await request.get({ url: `/school/device-gate-config/get` })
  },

  // 新增考勤设置
  createDeviceGateConfig: async (data: DeviceGateConfig) => {
    return await request.post({ url: `/school/device-gate-config/create`, data })
  },

  // 修改考勤设置
  updateDeviceGateConfig: async (data: DeviceGateConfig) => {
    return await request.put({ url: `/school/device-gate-config/update`, data })
  },

  // 删除考勤设置
  deleteDeviceGateConfig: async (id: number) => {
    return await request.delete({ url: `/school/device-gate-config/delete?id=` + id })
  },

  /** 批量删除考勤设置 */
  deleteDeviceGateConfigList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/device-gate-config/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出考勤设置 Excel
  exportDeviceGateConfig: async (params) => {
    return await request.download({ url: `/school/device-gate-config/export-excel`, params })
  }
}
